/**
 * 
 */
package org.bookie.mtest.framework;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xml.sax.SAXException;

import com.meterware.httpunit.WebResponse;
import com.meterware.httpunit.WebTable;

/**
 * Page that encapsulates logic inside category admin page
 * 
 * @author zubairov
 *
 */
public class CategoryAdminPage extends Page {

	private static final Log log = LogFactory.getLog(CategoryAdminPage.class);
	
	public CategoryAdminPage(WebResponse response) throws IOException, SAXException {
		super(response);
	}

	/**
	 * Returns a categories list on the page
	 * @return
	 * @throws SAXException 
	 */
	public Set<String> getCategories() throws SAXException {
		Set<String> result = new HashSet<String>();
		WebTable table = resp.getTableWithID("categoryListTable");
		for(int i=0;i<table.getRowCount();i++) {
			result.add(table.getCellAsText(i, 0));
		}
		return result;
	}

}
